<extend name="Public/baseConf"/>  
<block name="breadcrumb"> 
	<div class="row wrapper border-bottom white-bg page-heading">
	    <div class="col-lg-4">
	        <h2>软件管理</h2>
	        <ol class="breadcrumb">
	            <li><a href="{:U('index/index')}">首页</a></li>
	            <li><a href="{:U('Softwareversion/index')}">软件列表</a></li>
	            <li class="active">
	                <strong><if condition="$data eq null">新增软件<else/>编辑软件</if></strong>
	            </li>
	        </ol>
	    </div>
	    <div class="col-lg-6"></div>
	    <div class="col-lg-2">
            <div class="title-action">
           		<button class="btn btn-primary ajax-post" type="submit" target-form="form">
           		<i class="fa fa-pencil align-top"></i>确定
           		</button> 
            </div>
        </div>
	</div> 
</block>
<block name="body">
	<div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
	        <div class="col-lg-12">
	            <div class="ibox float-e-margins">
	                <div class="ibox-title">
	                    <h5><if condition="$data eq null">新增<else/>编辑({$data['name']})</if>信息</h5>
	                    <div class="ibox-tools">
	                        <a class="collapse-link">
	                            <i class="fa fa-chevron-up"></i>
	                        </a>
	                    </div>
	                </div>
	                <div class="ibox-content">
		                <form action="{:U('save')}" method="post" class="form">
		                    <div class="row">
		                    	<input type="hidden" name="id" value="{$data['id']}"/>
		                        <div class="col-sm-4 b-r">
	                                <div class="form-group">
	                                	<label>软件名称</label> 
	                                	<select id="name" name="name" class="form-control">
											<option value="名品宜家" <eq name="data['name']" value="名品宜家">selected</eq>>名品宜家</option>
										</select>
	                                </div>
	                                <div class="form-group">
	                                	<label>版本号</label> 
	                                	<input type="text" id="version" name="version" value="{$data['version']}" placeholder="必填项" class="form-control">
	                                </div>
		                        </div>
		                        <div class="col-sm-4 b-r">
		                        	<div class="form-group">
	                                	<label>发布时间</label> 
	                                	<div class="input-group date">
			                                <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
			                                <input id="publish" name="publish" value="{$data['publish']}" placeholder="必填项" class="form-control" required="" type="text" >
			                            </div>
	                                </div>
	                                <div class="form-group">
										<input type="file" id="upload_file_fileid">
										<input type="hidden" name="fileid" value="{:think_encrypt(json_encode(get_table_field($data['fileid'],'id','','File')))}"/>
										<div class="upload-img-box">
											<present name="data['fileid']">
												<div class="upload-pre-file">
												<span class="label label-Primary">{$data['fileid']|get_table_field=###,'id','name','File'}</span>
												</div>
											</present>
										</div>
									</div>
									
									
		                        </div>
		                        <div class="col-sm-4">
		                        	<div class="form-group">
	                                	<label>备注</label> 
	                                	<textarea id="comments"  rows="4" name="comments" class="form-control">{$data['comments']}</textarea>
	                                </div>
		                        </div>
		                    </div>
		                    <div class="row">
		                        <div class="col-sm-12 b-r">
	                                <div class="form-group">
	                                	<label>版本说明</label> 
	                                	<textarea name="description" class="form-control">{$data['description']}</textarea>
				                        {:hook('adminArticleEdit', array('name'=>'description','value'=>$data['description']))}
	                                </div>
		                        </div>
		                    </div>
	                    </form>
	                </div>
	            </div>
	        </div>
        </div>
        <div class="row">
	        <div class="col-lg-12">
	        	<div class="ibox float-e-margins">
	                <div class="ibox-title">
	                    <h5>软件列表</h5>
	                    <div class="ibox-tools">
	                        <a class="collapse-link">
	                            <i class="fa fa-chevron-up"></i>
	                        </a>
	                    </div>
	                </div>
	                <div class="ibox-content">
	                	<input type="text" class="form-control input-sm m-b-xs" id="filter" placeholder="快速检索">

	                    <table class="footable table table-stripped" data-page-size="10" data-filter=#filter>
	                        <thead>
	                        <tr>
								<th class="row-selected row-selected">
								<label><input type="checkbox" class="check-all" /><span class="lbl"></span></label></th>
			                    <th class="center">ID</th>
			                    <th class="center">软件名称</th>
			                    <th class="center">版本号</th>
			                    <th class="center">文件</th>
			                    <th class="center">发布时间</th>
			                    <th class="center">状态</th>
			                    <!-- <th class="center">版本说明</th> -->
			                    <th class="center">备注</th>
			                    <th class="center">操作</th>
								<th></th>
	                        </tr>
	                        </thead>
	                        <tbody>
	                        <tr class="gradeX">
								<notempty name="_list">
								<volist name="_list" id="vo">
								<tr>
						            <td class="center">
										<label>
											<input type="checkbox" class="ids row-selected" name="id[]" value="{$vo.id}"/>
											<span class="lbl"></span>
										</label>
									</td>
									<td>{$vo.id}</td>
			                        <td>{$vo.name}</td>
			                        <td>V{$vo.version}</td>
			                        <td>
				                        <a title="下载" href="{:U('File/download2?id='.$vo['fileid'])}"><i class="text-navy fa fa-cloud-download bigger-250"></i>
				                        {$vo.fileid|get_table_field=###,'id','name','File'}
				                        </a>
			                        </td>
			                        <td>{$vo.publish}</td>
			                        <td>{$vo.status_text}</td>
			                        <!-- <td>{$vo.description}</td> -->
			                        <td>{$vo.comments}</td>
			                        <td class="center">
			                        	
			                        	<a title="禁用" class="ajax-get" href="{:U('changeStatusSingle?method=forbid&id='.$vo['id'])}"><i class="text-danger fa fa-flag bigger-250"></i></a>
			                        	<a title="启用" class="ajax-get" href="{:U('changeStatusSingle?method=resume&id='.$vo['id'])}"><i class="text-navy fa fa-flag bigger-250"></i></a>
			                        	<a title="编辑" href="{:U('edit?id='.$vo['id'])}"><i class="text-navy fa fa-pencil bigger-250"></i></a>
						                <a title="删除" class="ajax-get" href="{:U('delete?id='.$vo['id'])}"><i class="text-danger fa fa-trash-o bigger-250"></i></a>
			                        </td>
						            <td></td>
								</tr>
								</volist>
								<else/> 
								<td colspan="9" class="text-center"> aOh! 暂时还没有内容! </td>
								</notempty>
	                        </tr>
	                        </tbody>
	                        <tfoot>
	                        <tr>
	                            <td colspan="9">
	                                <ul class="pagination pull-right"></ul>
	                            </td>
	                        </tr>
	                        </tfoot>
	                    </table>
	                </div>
	            </div>
	        </div>
        </div>
    </div>
	<!-- 分页 -->
    <!-- <div class="page">
        {$_page}
    </div>  --> 
</block>  
<block name="script">
	<script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
	<script src="__INSPINIA__/js/plugins/footable/footable.all.min.js"></script>
	<script>
	   $('.footable').footable();
    </script>
	<script type="text/javascript">
	 	$('.date').datepicker({});
	    /* 初始化上传插件 */
		$("#upload_file_fileid").uploadify({
	        "height"          : 30,
	        "swf"             : "__STATIC__/uploadify/uploadify.swf",
	        "fileObjName"     : "download",
	        "buttonText"      : "上传附件",
	        "uploader"        : "{:U('File/upload',array('session_id'=>session_id()))}",
	        "width"           : 120,
	        'removeTimeout'	  : 1,
	        "onUploadSuccess" : uploadFilefileid,
	        'onFallback' : function() {
	            alert('未检测到兼容版本的Flash.');
	        }
	    });
		function uploadFilefileid(file, data){
			var data = $.parseJSON(data);
	        if(data.status){
	        	$("input[name='fileid']").val(data.data);
	        	$("input[name='fileid']").parent().find('.upload-img-box').html(
	        		"<div class=\"upload-pre-file\"><span class=\"label label-Primary\">" + data.info + "</span></div>"
	        	);
	        } else {
	        	updateAlert(data.info);
	        	setTimeout(function(){
	                $('#top-alert').find('button').click();
	                $(this).removeClass('disabled').prop('disabled',false);
	            },1500);
	        }
	    }
		</script>	
</block>
